#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pygame
from utils import load_image
from pygame.locals import *
from math import sqrt
'''
    * (Level 1): Scratch (OK)
    * (Level 1): Growl
    * (Level 7): Ember (OK)
    * (Level 10): SmokeScreen
    * (Level 17): Dragon Rage
    * (Level 21): Scary Face
    * (Level 28): Fire Fang
    * (Level 32): Slash
    * (Level 39): Flamethrower
    * (Level 43): Fire Spin
'''
class Scratch(pygame.sprite.Sprite):
	def __init__(self, startpos, position_inicial):
		pygame.sprite.Sprite.__init__(self)
		self.velocity = 1
		self.speed = [1,1]
		self.init_pos = startpos #posição do mouse
		self.mouse_pos_X, self.mouse_pos_Y = self.init_pos #posição do mouse INICIAL
		self.image, self.rect = load_image('Scratch.png')
		self.rect.centerx, self.rect.centery = self.init_pos
		self.fire_position_x, self.fire_position_y = position_inicial #posição para onde a bola tem de ir FINAL
		self.dead = False
		#self.balls.append(self) #Adiciona cada bola no vetor para verificar a colisão

	def get_rect(self):
		return self.image.get_rect()

	def update(self):
		self.Walking()
		
	def render(self, screen):
		self.update()
		screen.blit(self.image, (self.fire_position_x, self.fire_position_y))
       
	def Walking(self):
		if self.dead == False:
			direction  = (self.mouse_pos_X - self.fire_position_x, self.mouse_pos_Y - self.fire_position_y) 
			direction_lenght = sqrt(direction[0]*direction[0] + direction[1]*direction[1])
			if direction_lenght < 20:
				self.dead = True
				self.fire_position_x = -100
				self.fire_position_y = -100			
			else:
				direction = (direction[0] /direction_lenght) * self.velocity, ( direction[1] / direction_lenght) * self.velocity
				self.fire_position_x += direction[0]
				self.fire_position_y += direction[1]	

class Ember(pygame.sprite.Sprite):
	def __init__(self, startpos, position_inicial):
		pygame.sprite.Sprite.__init__(self)
		self.velocity = 1
		self.speed = [1,1]
		self.init_pos = startpos #posição do mouse
		self.mouse_pos_X, self.mouse_pos_Y = self.init_pos #posição do mouse INICIAL
		self.image, self.rect = load_image('FireBall.png')
		self.rect.centerx, self.rect.centery = self.init_pos
		self.fire_position_x, self.fire_position_y = position_inicial #posição para onde a bola tem de ir FINAL
		self.dead = False
		#self.balls.append(self) #Adiciona cada bola no vetor para verificar a colisão
	

	def get_rect(self):
		return self.image.get_rect()

	def update(self):
		self.Walking()
		
	def render(self, screen):
		self.update()
		screen.blit(self.image, (self.fire_position_x, self.fire_position_y))
       
	def Walking(self):
		if self.dead == False:
			direction  = (self.mouse_pos_X - self.fire_position_x, self.mouse_pos_Y - self.fire_position_y) 
			direction_lenght = sqrt(direction[0]*direction[0] + direction[1]*direction[1])
			if direction_lenght < 20:
				self.dead = True
				self.fire_position_x = -100
				self.fire_position_y = -100			
			else:
				direction = (direction[0] /direction_lenght) * self.velocity, ( direction[1] / direction_lenght) * self.velocity
				self.fire_position_x += direction[0]
				self.fire_position_y += direction[1]
				
				
'''
Pidgey
    * (Level 1): Tackle
    * (Level 5): Sand-Attack
    * (Level 9): Gust
    * (Level 13): Quick Attack
    * (Level 17): Whirlwind
    * (Level 21): Twister
    * (Level 25): FeatherDance
    * (Level 29): Agility
    * (Level 33): Wing Attack
    * (Level 37): Roost
    * (Level 41): Tailwind
    * (Level 45): Mirror Move
    * (Level 49): Air Slash
    * (Level 53): Hurricane
'''    				

